import { Window_CommandList } from "@/windows/Window_CommandList.js";
import { TextManager } from "@/managers/TextManager.js";

export class Window_ActorCommand extends Window_CommandList {
    constructor(width,height) {
        super(width,height);
    }

    init(width,maxHeight) {
        this._actor = null;
        super.init(width,maxHeight);
    }

    makeCommands() {
        if (this._actor) {
            this.addCommand(TextManager.attack,'attack',null,this._actor.canAttack());
            this.addSkillCommands();
            this.addCommand(TextManager.guard, 'guard',null,this._actor.canGuard());
            this.addCommand(TextManager.item,'item');
        }
    }

    addSkillCommands() {
        let skillTypes = this._actor.addedSkillTypes().sort((a,b)=>a-b);
        for(let stypeId of skillTypes){
            let name = $dataSystem.skillTypes[stypeId];
            this.addCommand(name, 'skill',stypeId);
        }
    }

    setActor(actor) {
        this._actor = actor;
        this.makeCommandList();
        this.refresh();
    }
}